Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls


<ToolboxData("<{0}:TemplateControl runat=server></{0}:TemplateControl>")> _
Public Class TemplateControl
    Inherits WebControl

    Private TemplateHolder As ITemplate = Nothing


    <TemplateContainer(GetType(TemplateManager)), _
             PersistenceMode(PersistenceMode.InnerProperty)> _
    Public Property TemplateManager() As ITemplate
        Get
            Return TemplateHolder
        End Get
        Set(ByVal value As ITemplate)
            TemplateHolder = value
        End Set
    End Property

    Private Sub TemplateControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim tm As TemplateManager

        If Not (TemplateHolder Is Nothing) Then
            tm = New TemplateManager
            TemplateHolder.InstantiateIn(tm)
            Me.Controls.Add(tm)

            tm = New TemplateManager
            TemplateHolder.InstantiateIn(tm)
            Me.Controls.Add(tm)
        End If

    End Sub
End Class
